import request from "@/utils/request";
import { PositionQuery, Position, PositionForm } from "./types";
import { AxiosPromise } from "axios";

export function getPositionPage(
  queryParams?: PositionQuery
): AxiosPromise<PageResult<Position[]>> {
  return request({
    url: "/admin/position/index",
    method: "get",
    params: queryParams,
  });
}

export function getPositionAll(): AxiosPromise<OptionType[]> {
  return request({
    url: "/admin/position/all",
    method: "get",
  });
}

export function positionDisable(data: any) {
  return request({
    url: "/admin/position/disable",
    method: "post",
    data,
  });
}

export function positionEnable(data: any) {
  return request({
    url: "/admin/position/enable",
    method: "post",
    data,
  });
}

export function createPosition(data: any) {
  return request({
    url: "/admin/position/add",
    method: "post",
    data,
  });
}

export function updatePosition(data: any) {
  return request({
    url: "/admin/position/edit",
    method: "put",
    data,
  });
}

export function delPosition(data: any) {
  return request({
    url: "/admin/position/del",
    method: "delete",
    data,
  });
}

export function getPositionForm(ids: number): AxiosPromise<PositionForm> {
  return request({
    url: "/admin/position/edit",
    method: "get",
    params: {
      ids: ids,
    },
  });
}
